<?php

namespace IDock\Insurance\TPBX\Request;

use IDock\Http\RequestFormat;
use IDock\Insurance\TPBX\Request\AllTPBXRequest;
use IDock\Insurance\TPBX\Response\PolicyPaymentResponse;
use IDock\Printer\NonCar\NonCarInquirySinglePrinter;
use IDock\Visitor\PolicyPaymentVisitor;
use stdClass;

class PolicyPaymentRequest extends AllTPBXRequest
{
    public $requestType = 'V906';

    public $route = 'webapi/v1/pay/apply';

    protected $response = PolicyPaymentResponse::class;

    protected $urlTip = '支付接口';
    /**
     * @var  PolicyPaymentVisitor $visitor
     */
    protected $visitor;

    public $url;

    public function generate(): array
    {
        $policyNoList = [];
        if(!empty($this->visitor->biInquiryNo)){
            $policyNoList[] = ['applyPolicyNo' => $this->visitor->biInquiryNo];
        }
        if(!empty($this->visitor->ciInquiryNo)){
            $policyNoList[] = ['applyPolicyNo' => $this->visitor->ciInquiryNo];
        }
        if(!empty($this->visitor->argc['nonCarInquiryNo'])){
            $policyNoList[] = ['applyPolicyNo' => $this->visitor->argc['nonCarInquiryNo']];
        }
        $data = [
            'payQrcodeInfo' => [
                'applyPolicyList' => $policyNoList,
                'vehicleFrameNo' => $this->visitor->argc['vin'] ?? '',
                'resultType' => '0',//0-返回URL地址
                'backNotifyUrl' => $this->url,
            ],
        ];
        return $data;
    }
}
